<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
mm_showMyFileName(__FILE__);
// additional params
include(dirname(__FILE__).DS.'includes'.DS.'productdetails_params.php');
 ?>

<?php echo $buttons_header // The PDF, Email and Print buttons ?>
<!-- ontology -->
<span typeof="owl:Ontology" about="">
	<span property="dc:creator" datatype="xsd:string" content="<?php echo $vendor_name ?>"></span>
	<span rel="owl:imports" resource="<?php echo substr($namespaces['gr'], 0, -1) ?>"></span>
	<span property="rdfs:label" datatype="xsd:string" content="RDF/XML data for <?php echo $vendor_store_name ?>, based on http://purl.org/goodrelations/"></span>
</span>
<?php
if( $this->get_cfg( 'showPathway' )) {
	echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( $this->get_cfg( 'product_navigation', 1 )) {
	if( !empty( $previous_product )) {
		echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
	}
	if( !empty( $next_product )) {		
		echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
	}
}
?>
<!-- vendor / store owner -->
<span typeof="gr:BusinessEntity" about="#Vendor_<?php echo $vendor_id ?>">
	<span property="gr:legalName" datatype="xsd:string" content="<?php echo $vendor_store_name ?>"></span>
	<?php if(!empty($vendor_url)): ?>
	<a rel="rdfs:seeAlso" href="<?php echo $vendor_url ?>"></a>
	<?php endif ?>
	<span rel="vcard:adr">
		<span typeof="vcard:Address" about="#Address_<?php echo $vendor_id ?>">
			<?php if(!empty($vendor_postal_code)): ?>
			<span property="vcard:postal-code" content="<?php echo $vendor_postal_code ?>"></span>
			<?php endif; if(!empty($vendor_street_address)): ?>
			<span property="vcard:street-address" content="<?php echo strip_tags($vendor_street_address) ?>"></span>
			<?php endif; if(!empty($vendor_locality)): ?>
			<span property="vcard:locality" content="<?php echo $vendor_locality ?>"></span>
			<?php endif; if(!empty($vendor_region)): ?>
			<span property="vcard:region" content="<?php echo $vendor_region ?>"></span>
			<?php endif; if(!empty($vendor_country_name)): ?>
			<span property="vcard:country-name" content="<?php echo $vendor_country_name ?>"></span>
			<?php endif ?>
		</span>
	</span>
	<?php if(!empty($vendor_url)): ?>
	<a rel="vcard:url" href="<?php echo $vendor_url ?>"></a>
	<?php endif; if(!empty($vendor_email)): ?>
	<span property="vcard:email" content="<?php echo $vendor_email ?>"></span>
	<?php endif; if(!empty($vendor_phone)): ?>
	<span property="vcard:tel" content="<?php echo $vendor_phone ?>"></span>
	<?php endif; if(!empty($vendor_fax)): ?>
	<span property="vcard:fax" content="<?php echo $vendor_fax ?>"></span>
	<?php endif ?>
	<span rel="gr:offers" resource="#Offering_<?php echo $product_id ?>"></span>
</span>
<!-- categories -->
<?php
if(sizeof($category)>0)
foreach($category as $cat_item) {
?>
<span typeof="owl:Class" about="#Category_<?php echo $cat_item['id'] ?>">
<?php if($cat_item['parent_id'] == 0): /* must be a super category */ ?>	<span rel="rdfs:subClassOf" resource="<?php echo $namespaces['gr'] ?>ProductOrService"></span>
<?php else: ?>	<span rel="rdfs:subClassOf" resource="#Category_<?php echo $cat_item['parent_id'] ?>"></span>
<?php endif ?>
	<span property="rdfs:label" datatype="xsd:string" content="<?php echo $cat_item['name'] ?> (Catalog Group / Category)"></span>
	<?php if(!empty($cat_item['description'])): ?>
	<span property="rdfs:comment" datatype="xsd:string" content="<?php echo strip_tags($cat_item['description']) ?>"></span>
	<?php endif ?>
</span>
<?php
}
?>
<!-- object properties -->
<?php
$object_properties = array("Weight", "Length", "Width", "Height");
foreach ($object_properties as $object_property) {
?>
<span typeof="owl:ObjectProperty" about="#hasProduct<?php echo $object_property ?>">
	<span property="rdfs:label" datatype="xsd:string" content="Product <?php echo $object_property ?> Property"></span>
	<span property="rdfs:comment" datatype="xsd:string" content="This property specifies the <?php echo $object_property ?> of a Product or Service."></span>
	<span rel="rdfs:subPropertyOf" resource="<?php echo $namespaces['gr'] ?>quantitativeProductOrServiceProperty"></span>
	<span rel="rdfs:domain" resource="<?php echo $namespaces['gr'] ?>ProductOrService"></span>
	<span rel="rdfs:range" resource="<?php echo $namespaces['gr'] ?>QuantitativeValueFloat"></span>
</span>
<?php
}

if($price_quantity_start>0 || $price_quantity_end>0): /* eligible product quantity for price specification */ ?>
<!-- eligible quantity -->
<span typeof="gr:QuantitativeValueInteger" about="#QuantitativeValueInteger_EligibleQuantity_<?php echo $product_id ?>">
	<?php if($price_quantity_start>0): ?><span property="gr:hasMinValueInteger" datatype="xsd:int" content="<?php echo $price_quantity_start ?>"></span><?php endif ?>
	<?php if($price_quantity_end>0): ?><span property="gr:hasMaxValueInteger" datatype="xsd:int" content="<?php echo $price_quantity_end ?>"></span><?php endif ?>
	<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
</span>
<?php endif ?>
<br style="clear:both;" />
<!-- offering -->
<?php
$product_available_date = time();
if($param['offering_validity'] <= 0)
	$offering_validity = 1;
else
	$offering_validity = $param['offering_validity'];
?>
<table border="0" style="width: 100%;">
  <tbody typeof="gr:Offering" about="#Offering_<?php echo $product_id ?>">
	<tr typeof="gr:BusinessEntity" about="#Manufacturer_<?php echo $manufacturer_id ?>">
<?php  if( $this->get_cfg('showManufacturerLink') ) { $rowspan = 5; } else { $rowspan = 4; } ?>
	  <td width="33%" rowspan="<?php echo $rowspan; ?>" valign="top"><br/>
	  	<?php echo $product_image ?><br/><br/><?php echo $this->vmlistAdditionalImages( $product_id, $images ) ?></td>
	  <td rowspan="1" colspan="2">
	  <h1><?php echo $product_name ?> <?php echo $edit_link ?></h1>
	  <span property="gr:legalName" datatype="xsd:string" content="<?php echo $manufacturer_name ?>"></span>
	  <?php if(!empty($manufacturer_url)): ?>
	  <a rel="rdfs:seeAlso" href="<?php echo $manufacturer_url ?>"></a>
	  <?php endif; if(!empty($manufacturer_description)): ?>
	  <span property="rdfs:comment" datatype="xsd:string" content="<?php echo strip_tags($manufacturer_description) ?>"></span>
	  <?php endif ?>
	  </td>
	</tr>
	<?php if( $this->get_cfg('showManufacturerLink')) { ?>
		<tr>
		  <td rowspan="1" colspan="2"><?php echo $manufacturer_link ?><br /></td>
		</tr>
	<?php } ?>
	<tr>
      <td width="33%" valign="top" align="left">
      	<?php echo $product_price_lbl ?>
		<span rel="gr:hasPriceSpecification">
			<span typeof="gr:UnitPriceSpecification" about="#UnitPriceSpecification_<?php echo $product_id ?>">
				<span property="gr:hasCurrencyValue" datatype="xsd:float" content="<?php echo number_format($product_base_price, 2, '.', '') ?>"><?php echo $product_price ?></span>
				<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
				<span property="gr:hasCurrency" datatype="xsd:string" content="<?php echo $product_currency ?>"></span>
				<span property="gr:valueAddedTaxIncluded" datatype="xsd:boolean" content="<?php echo $tax_included?'true':'false' ?>"></span>
				<?php if($price_quantity_start>0 || $price_quantity_end>0): /* eligible product quantity for price specification */ ?>
				<span rel="gr:hasEligibleQuantity" resource="#QuantitativeValueInteger_EligibleQuantity_<?php echo $product_id ?>""></span>
				<?php endif ?>
				<span property="gr:validFrom" datatype="xsd:dateTime" content="<?php echo w3cdate($product_available_date) ?>"></span>
				<span property="gr:validThrough" datatype="xsd:dateTime" content="<?php echo w3cdate($product_available_date, $offering_validity) ?>"></span>
			</span>
		</span>
		<?php if($product_special == 'Y'): ?>
		<span rel="gr:hasPriceSpecification">
			<span typeof="gr:UnitPriceSpecification" about="#UnitPriceSpecification_<?php echo $product_id ?>_Special">
				<span property="rdfs:comment" datatype="xsd:string" content="Special price offer"></span>
				<span property="gr:hasCurrencyValue" datatype="xsd:float" content="<?php echo number_format($product_special_price, 2, '.', '') ?>"></span>
				<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
				<span property="gr:hasCurrency" datatype="xsd:string" content="<?php echo $product_currency ?>"></span>
				<span property="gr:valueAddedTaxIncluded" datatype="xsd:boolean" content="<?php echo $tax_included?'true':'false' ?>"></span>
				<?php if($product_special_start_date != 0): ?>
				<span property="gr:validFrom" datatype="xsd:dateTime" content="<?php echo w3cdate($product_special_start_date) ?>"></span>
				<?php endif ?>
				<?php if($product_special_end_date != 0 && $product_special_start_date<$product_special_end_date): ?>
				<span property="gr:validThrough" datatype="xsd:dateTime" content="<?php echo w3cdate($product_special_end_date) ?>"></span>
				<?php elseif($product_special_start_date != 0): // no end date specified, take 1 day as default ?>
				<span property="gr:validThrough" datatype="xsd:dateTime" content="<?php echo w3cdate($product_special_start_date, ($param['special_validity']>0)?$param['special_validity']:1) ?>"></span>
				<?php endif ?>
				<?php if($price_quantity_start>0 || $price_quantity_end>0): /* eligible product quantity for price specification */ ?>
				<span rel="gr:hasEligibleQuantity" resource="#QuantitativeValueInteger_EligibleQuantity_<?php echo $product_id ?>""></span>
				<?php endif ?>
			</span>
		</span>
		<?php endif ?>
		<?php if(!empty($product_url)): ?>
		<a rel="rdfs:seeAlso" href="<?php echo $product_url ?>"></a>
		<?php endif ?>
		<br /></td>
      <td valign="top"><?php echo $product_packaging ?><br /></td>
	</tr>
	<tr>
	  <td colspan="2"><?php echo $ask_seller ?></td>
	</tr>
	<tr>
	  <td rowspan="1" colspan="2"><hr />
		<span rel="gr:includesObject">
			<span typeof="gr:TypeAndQuantityNode" about="#TypeAndQuantityNode_<?php echo $product_id ?>">
				<span property="gr:amountOfThisGood" datatype="xsd:float" content="<?php echo /*$product_in_stock*/"1.0" ?>"></span>
				<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
				<span rel="gr:typeOfGood">
					<span typeof="<?php echo !empty($category[0]['id'])?"self:Category_".$category[0]['id']." ":"" ?>gr:ProductOrServicesSomeInstancesPlaceholder" about="#ProductOrServiceInstance_<?php echo $product_id ?>">
					<span property="rdfs:label" datatype="xsd:string" content="<?php echo $product_name ?> (ProductOrServicesSomeInstancesPlaceholder)"></span>
					<?php if(!empty($product_description)): ?>
					<span property="rdfs:comment" datatype="xsd:string"><?php echo $product_description ?></span>
					<?php elseif(!empty($product_s_desc)): ?>
					<span property="rdfs:comment" datatype="xsd:string" content="<?php echo strip_tags($product_s_desc) ?>"></span>
					<?php endif; ?>
					<?php if(!empty($product_url)): ?>
					<a rel="rdfs:seeAlso" href="<?php echo $product_url ?>"></a>
					<?php
					endif;
					// inventory level
					if(!empty($product_in_stock)): ?>
					<span rel="gr:hasInventoryLevel">
						<span about="#QuantitativeValueFloat_ProductInventoryLevel_<?php echo $product_id ?>" typeof="gr:QuantitativeValueFloat">
							<span property="rdfs:label" datatype="xsd:string" content="Inventory level of <?php echo $product_name ?>"></span>
							<span property="rdfs:comment" datatype="xsd:string" content="<?php echo number_format($product_in_stock, 1, '.', '') ?> pieces of <?php echo $product_name ?> are on stock"></span>
							<span property="gr:hasValueFloat" datatype="xsd:float" content="<?php echo number_format($product_in_stock, 1, '.', '') ?>"></span>
							<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
						</span>
					</span>
					<?php
					endif;
					// object properties
					foreach($object_properties as $object_property) {
						$object_property_lower = strtolower($object_property);
						$object_property_value = 'product_'.$object_property_lower;
						if(floatval($$object_property_value) != 0.) {
					?>
					<span rel="self:hasProduct<?php echo $object_property ?>">
						<span typeof="gr:QuantitativeValueFloat" about="#QuantitativeValueFloat_Product<?php echo $object_property."_".$product_id ?>">
							<span property="rdfs:label" datatype="xsd:string" content="<?php echo $object_property ?> description for <?php echo $product_name ?>"></span>
							<span property="rdfs:comment" datatype="xsd:string" content="<?php echo $product_name ?> has a <?php echo strtolower($object_property) ?> of <?php echo number_format($$object_property_value, 2, '.', '')." ".($object_property=="Weight"?$uom_weight:$uom_lwh) ?>"></span>
							<span property="gr:hasValueFloat" datatype="xsd:float" content="<?php echo number_format($$object_property_value, 2, '.', '') ?>"></span>
							<span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="<?php echo $object_property=="Weight"?$uom_weight:$uom_lwh//$product_weight_uom:$product_lwh_uom ?>"></span>
						</span>
					</span>
					<?php
						}
					}
					?>
					
					<span rel="gr:hasMakeAndModel">
							<span typeof="<?php echo !empty($category[0]['id'])?"self:Category_".$category[0]['id']." ":"" ?>gr:ProductOrServiceModel" about="#ProductOrServiceModel_<?php echo $product_id ?>">
								<span property="rdfs:label" datatype="xsd:string" content="<?php echo $product_name ?> (ProductOrServiceModel)"></span>
								<?php if(!empty($product_description)): ?>
								<span property="rdfs:comment" datatype="xsd:string" content="<?php echo strip_tags($product_description) ?>"></span>
								<?php elseif(!empty($product_s_desc)): ?>
								<span property="rdfs:comment" datatype="xsd:string" content="<?php echo strip_tags($product_s_desc) ?>"></span>
								<?php endif; ?>
								<span rel="gr:hasManufacturer" resource="#Manufacturer_<?php echo $manufacturer_id ?>"></span>
								<?php if(!empty($product_url)): ?>
								<a rel="rdfs:seeAlso" href="<?php echo $product_url ?>"></a>
								<?php
								endif;
								// object properties
								foreach($object_properties as $object_property) {
									$object_property_lower = strtolower($object_property);
									$object_property_value = 'product_'.$object_property_lower;
									if(floatval($$object_property_value) != 0.) {
								?>
								<span rel="self:hasProduct<?php echo $object_property ?>" resource="#QuantitativeValueFloat_Product<?php echo $object_property."_".$product_id ?>"></span>
								<?php
									}
								}
								?>
							</span>
						</span>
					</span>
				</span>
			</span>
		</span>
		<br/>
	  	<span style="font-style: italic;"><?php echo $file_list ?></span>
	  </td>
	</tr>
	<tr>
	  <td><?php 
	  		if( $this->get_cfg( 'showAvailability' )) {
	  			echo $product_availability; 
	  		}
	  		?>
			<span property="gr:validFrom" datatype="xsd:dateTime" content="<?php echo w3cdate($product_available_date) ?>"></span>
			<span property="gr:validThrough" datatype="xsd:dateTime" content="<?php echo w3cdate($product_available_date, $offering_validity) ?>"></span>
			<br />
			<?php
			if(!empty($product_sku)):
			?>
			<span property="gr:hasStockKeepingUnit" datatype="xsd:string" content="<?php echo $product_sku ?>"></span>
			<?php
			endif;
			// offering details got from master data in the backend
			foreach($elements as $element) {
			
				$property = NULL;
				$parameter_array_name = strtolower(ereg_replace('^_', '', ereg_replace('[A-Z]','_\\0',$element)));
				
				switch($element) {
					/*case 'BusinessFunction':
						$property = 'has'.$element;
					break;*/
					case 'BusinessEntityType':
						$property = 'eligibleCustomerTypes';
					break;
					case 'DeliveryMethod':
						$property = 'available'.$element.'s';
					break;
					case 'PaymentMethod':
						$property = 'accepted'.$element.'s';
					break;
					case 'WarrantyScope':
						$property = 'hasWarrantyPromise';
					break;
				}
				
				$$parameter_array_name = getAllParametersFromElement($element); // get parameters from backend
				if($$parameter_array_name != NULL && $property != NULL) {
					if($element == 'WarrantyScope') {
						foreach($$parameter_array_name as $key => $value) {
							$duration = getAllParametersFromElement($key."_duration");
							foreach($duration as $value) {
			?>
			<span rel="gr:<?php echo $property ?>">
				<span typeof="gr:WarrantyPromise" about="#WarrantyPromise_<?php echo $key ?>">
					<span property="rdfs:label" datatype="xsd:string" content="Warranty promise for <?php echo $key ?>"></span>
					<span property="rdfs:comment" datatype="xsd:string" content="Warranty duration of <?php echo $value." months for ".$key ?>"></span>
					<span property="gr:durationOfWarrantyInMonths" datatype="xsd:int" content="<?php echo $value ?>"></span>
					<span rel="gr:hasWarrantyScope" resource="<?php echo $namespaces['gr'].$key ?>"></span>
				</span>
			</span>
			<?php
							}
						}
					}
					else {
						foreach($$parameter_array_name as $key => $value) {
			?>
			<span rel="gr:<?php echo $property ?>" resource="<?php echo $namespaces['gr'].$key ?>"></span>
			<?php
						}
					}
				}
			}
			// business function
			if(($business_function = getAllParametersFromElement('BusinessFunction')) != NULL) {
				foreach ($business_function as $key => $value) {
			?>
			<span rel="gr:hasBusinessFunction" resource="<?php echo $namespaces['gr'].$value ?>"></span>
			<?php
				}
			}
			// eligible regions
			if(($eligible_regions = getAllParametersFromElement('eligibleRegions')) != NULL) {
				foreach ($eligible_regions as $key => $value) {
					$regions_array = explode(',', $value);
					if(sizeof($regions_array)>0)
					foreach($regions_array as $region_code) {
					   if(trim($region_code)!="") {
				?>
				<span property="gr:eligibleRegions" datatype="xsd:string" content="<?php echo trim($region_code) ?>"></span>
				<?php
					   }
					}
				}
			}
			?>
	  </td>
	  <td colspan="2"><br /><?php echo $addtocart ?></td>
	</tr>
	<tr>
	  <td colspan="3"><?php echo $product_type ?></td>
	</tr>
	<tr>
	  <td colspan="3"><hr /><?php echo $product_reviews ?></td>
	</tr>
	<tr>
	  <td colspan="3"><?php echo $product_reviewform ?><br /></td>
	</tr>
	<tr>
	  <td colspan="3"><?php echo $related_products ?><br />
	   </td>
	</tr>
	<?php if( $this->get_cfg('showVendorLink')) { ?>
		<tr>
		  <td colspan="3"><div style="text-align: center;"><?php echo $vendor_link ?><br /></div><br /></td>
		</tr>
	<?php  } ?>
  </tbody>
</table>
<?php 
if( !empty( $recent_products )) { ?>
	<div class="vmRecent">
	<?php echo $recent_products; ?>
	</div>
<?php 
}
if( !empty( $navigation_childlist )) { ?>
	<?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES') ?><br />
	<?php echo $navigation_childlist ?><br style="clear:both"/>
<?php 
} ?>
